home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / brklyprl.lha / Emulator / Tests / Passed / test47.pl < prev    next >
Encoding:
Text File  |  1989-04-14  |  526 b   |  27 lines

  1.  
  2. /* Copyright (C) 1988, 1989 Herve' Touati, Aquarius Project, UC Berkeley */
  3.  
  4. /*
  5.  * simple set and access 
  6.  * right now, the compiler only recognizes assert and retract
  7.  * as built-ins, not set and access.
  8.  * in this test and the followings, we will use 
  9.  * assert ---> for set
  10.  * retract ---> for access
  11.  */
  12.  
  13. main :- set(1), do_incr(24).
  14.  
  15. do_incr(0).
  16. do_incr(N) :- N1 is N - 1, incr, do_incr(N1).
  17.  
  18. incr :-
  19.     access(Count),
  20.     NCount is Count + 1,
  21.     write(Count), nl,
  22.     set(NCount).
  23.  
  24. access(N) :- access(0,N).
  25. set(N) :- set(0,N).
  26.  
  27.